<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .error{
            color: red;
            font-size: 12px;
        }
    </style>
    <script src="/js/axios.min.js"></script>
    <script src="/js/util.js"></script>
    <script>
        function add(){
            $("nameSpan").innerHTML = "";
            $("birthdaySpan").innerHTML = "";
            $("moneySpan").innerHTML = "";
            $("emailSpan").innerHTML = "";

            axios.get("/em/add",{
                params:{
                    name:$("name").value,
                    birthday:$("birthday").value,
                    money:$("money").value,
                    email:$("email").value
                }
            }).then(resp =>{
                var info = resp.data;
                if(info == "ok"){
                    alert("验证通过");
                }
                else{
                    info.forEach(n =>{
                        $(n.field + "Span").innerHTML = n.defaultMessage;
                    });
                }

            })
        }
    </script>
</head>
<body>
    姓名：<input type="text" id="name"><span class="error" id="nameSpan"></span><br>
    生日：<input type="text" id="birthday"><span class="error" id="birthdaySpan"></span><br>
    工资：<input type="text" id="money"><span class="error" id="moneySpan"></span><br>
    邮箱：<input type="text" id="email"><span class="error" id="emailSpan"></span><br>
    <input type="button" value="提交" onclick="add()">
</body>
</html>